home *** CD-ROM | disk | FTP | other *** search
/ Info-Mac 4 / Info_Mac IV CD-ROM (Pacific HiTech Inc.)(August 1994).iso / Development / Source / GENetReleaseƒ / GEDemo / Pogo.c < prev    next >
Text File  |  1994-03-07  |  2KB  |  65 lines

  1. /*
  2.     Pogo.c
  3.     
  4.     Boy on pogo stick for Graphic Elements demo
  5.     
  6.     Copyright 1993 by Al Evans. All rights reserved.
  7.     
  8.     11/10/93
  9. */
  10.  
  11. #include "Pogo.h"
  12. #include "Paths.h"
  13.  
  14.  
  15. //The bouncing and animation are handled as an interpreted "Path"
  16.     
  17. static PathEntry    pogoPathRec[11] =    {
  18.                                            {absMotionCmd, 3, 0, -22},
  19.                                          {repeatCmd, 10, 0, 0},
  20.                                          {relMotionCmd, 0, 0, 2},
  21.                                          {relMotionCmd, 4, 0, 0},
  22.                                          {repeatCmd, 10, 0, 0},
  23.                                          {relMotionCmd, 0, 0, 2},
  24.                                          {absMotionCmd, 5, 0, 0},
  25.                                          {absMotionCmd, 6, 0, 0},
  26.                                          {absMotionCmd, 1, 0, 0},
  27.                                          {absMotionCmd, 2, 0, 0},
  28.                                          {resetCmd, 0, 0, 0}
  29.                                          };
  30.  
  31. Boolean LoadPogoScene(GEWorldPtr world)
  32. {
  33.     GrafElPtr        thisElement;
  34.     PathRecPtr        pogoPath;
  35.  
  36.     //Get walking figure
  37.     thisElement = NewAnimatedGraphic(world, pogoID, pogoPlane, rPogoPic,
  38.                                 transparent, pogoLeft, pogoTop, 6);
  39.     if (thisElement == nil) return false;
  40.                                     
  41.     //Init path
  42.     pogoPath = (PathRecPtr) NewPtrClear(sizeof(PathRec));
  43.     InitPath(pogoPath);
  44.     pogoPath->path = pogoPathRec;
  45.     
  46.     //Init animation
  47.     SetAutoChange(world, pogoID, DoPogoStick, (Ptr) pogoPath, 67);
  48.     
  49.     thisElement->collisionPlane = 600;
  50.     
  51.     return true;
  52. }
  53.  
  54. pascal void DoPogoStick(GEWorldPtr world, GrafElPtr pogo)
  55. {
  56.     PathRecPtr pogoPath;
  57.     
  58.     pogoPath = (PathRecPtr) pogo->changeData;
  59.     GetNextStep(pogoPath);
  60.     if (pogoPath->currFrame)
  61.         SetFrame(world, pogo->objectID, pogoPath->currFrame);
  62.     if (pogoPath->currYMove)
  63.         MoveElement(world, pogo->objectID, 0, pogoPath->currYMove);
  64.     
  65. }